package OneAagin;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.time.LocalDate;

public class LogObj {
    static {
        File f = new File("log");
        if (f.exists()==false){
            f.mkdir();
        }
    }

    /**
     * 写入日志
     * @param info 写入的信息
     */
    public void writeLog(String info){
        Writer w = null;
        LocalDate date = LocalDate.now();
        try {
            w = new FileWriter("Log/"+date+".txt",true);
            w.write(info);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                w.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
